<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>this</title>
</head>
<body>
    
    <script>    
    
        {
            // this 

            let obj = {
                name: 'ws',
                age: 20,
                fn: function () {
                    console.log(this.name);
                }
            };

            console.log(obj.fn());

            // 自执行函数
            (function () {
                console.log(this);
            })();

        }

        {
            //  

            Array.prototype.fn = function () {
                console.log(this);
            }
            let ary = [1,2,3];

            console.log(ary.fn());
            
        }

        {

            // 

            window.setInterval(function () {
                console.log(this);
            },2000);

        }
    
    </script>

</body>
</html>